package com.ardf.common;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;

import java.io.IOException;
import java.time.LocalDateTime;

/**
 * 自定义localdate->localdatetime反序列化器
 * @author ShiYunHao
 * @since 2025-01-12
 */
public class CustomLocalDateToLocalDateTimeDeserializer  extends JsonDeserializer<LocalDateTime> {
    /**
     * 将字符串”2025-12-12“转成localdatetime
     * @param p
     * @param ctxt
     * @return
     * @throws IOException
     */
    @Override
    public LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
        String date = p.getText();
        return LocalDateTime.parse(date + "T00:00:00");
    }
}
